package com.example.springbootexamples;

import com.example.springbootexamples.domain.Child;
import org.apache.commons.io.FileUtils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.junit.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Vector;
import java.util.concurrent.Semaphore;

public class T {

    @Test
    public void t1(){
        RestTemplate restTemplate=new RestTemplate();

        MultiValueMap<String,String> multiValueMap=new LinkedMultiValueMap<>();

        multiValueMap.add("name","bob");

        HttpHeaders httpHeaders=new HttpHeaders();
        httpHeaders.add("application","ff");

        HttpEntity httpEntity=new HttpEntity(multiValueMap,httpHeaders);

        ResponseEntity responseEntity=restTemplate.postForEntity("http://localhost:8081/t",httpEntity,String.class);
        String body= (String) responseEntity.getBody();
        System.out.println(body);

        /*String str=restTemplate.getForObject("http://localhost:8080/t",String.class);
        System.out.println(str);*/


    }


    @Test
    public void t(){

        Child child=new Child();
        child.setName("aa");

        System.out.println(child.getName());

        Vector vector;
        Semaphore semaphore;

        System.out.println("a");
        System.out.println(5000==5000);

        try {

            File file=new File("/tmp/b");
            FileUtils.deleteDirectory(file);;

            /*Git git = Git.cloneRepository()
                    .setURI("https://github.com/eclipse/jgit.git")
                    .setDirectory(new File("/tmp/b"))
                    .setCredentialsProvider(new UsernamePasswordCredentialsProvider("admin","pass"))
                    .call();
*/
            /*File file=new File("/tmp/b");*/
            //FileUtils.deleteDirectory(file);;

        } catch (IOException e) {
            e.printStackTrace();
        }

    }


    @Test
    public void t23(){

        Double d1=1d;
        Double d2=1d;

        System.out.println(d1/d2);
        System.out.println(-0.0/0);


    }

}
